package com.rabbiter.ordering.service;

import com.rabbiter.ordering.entity.DishCategory;
import com.rabbiter.ordering.mapper.DishCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DishCategoryService {

        @Autowired
        private DishCategoryMapper categoryMapper;


        public List<DishCategory> listAll() {
            return categoryMapper.selectAll();
        }


        public DishCategory getById(Integer id) {
            return categoryMapper.selectById(id);
        }


        public boolean saveCategory(DishCategory category) {
            return categoryMapper.insert(category) > 0;
        }


        public boolean updateCategory(DishCategory category) {
            return categoryMapper.update(category) > 0;
        }


        public boolean deleteCategory(Integer id) {
            return categoryMapper.deleteById(id) > 0;
        }

    public List<DishCategory> getByName(DishCategory category) {
        return categoryMapper.selectByCondition(category);
    }
}

